//获取当前时间
var myDate = new Date();
var myYear = myDate.getFullYear(); //获取完整的年份(4位,1970-????)
var myMonth = myDate.getMonth()+1; //获取当前月份(0-11,0代表1月)
var myToday = myDate.getDate(); //获取当前日(1-31)
var myDay = myDate.getDay(); //获取当前星期X(0-6,0代表星期天)
var myHour = myDate.getHours(); //获取当前小时数(0-23)
var myMinute = myDate.getMinutes(); //获取当前分钟数(0-59)
var mySecond = myDate.getSeconds(); //获取当前秒数(0-59)
var newTime = myYear+'-'+myMonth+'-'+myToday+' '+myHour+':'+myMinute+':'+mySecond;
$('input[name=updateDate]').val(newTime);
layui.use(['jquery','layer','form','table','laydate','upload'],function() {
    var $ = layui.$, layer = layui.layer, form = layui.form, table = layui.table, laydate = layui.laydate,
        upload = layui.upload;

    form.on('submit',function(data){
        var roationChart = data.field;
        console.log(roationChart);
        $.ajax({
            url: '/advertisement/addAdvertisement'
            ,data: roationChart
            ,dataType: 'json'
            ,success:function(data){
                layer.msg('添加成功');
            }
        });
    });


    //修改头像
    var uploadInst = upload.render({
        elem: '#uploadImg'
        ,auto: true
        ,url: '/Upload/uploadImages'
        ,field: 'images'
        ,choose:function(obj){
            var files = obj.pushFile();
            obj.preview(function(index,file,result){
                $('#imgAddress').attr('src',result);
            })
        }
        ,done:function (res) {
            $('#disImg').show();
            $('input[name=imgAddress]').val(res.data);
        }
    });


})
//返回首页
function backOff(){
    parent.jumpSystemHome();
}